package com.htudata.core.util.operation;

import java.util.Properties;

public class SystemOperationUtils {

  private static final String SYSTEM_ENCODING = System.getProperty("sun.jnu.encoding");
  
  private static long beginTime;
  

  
  public static void begin() {
    beginTime = System.currentTimeMillis();
  }
  
  public static long getTotalTimeOfMiliSecond() {
    long result = System.currentTimeMillis() - beginTime;
    return result;
  }
  
  public static double getTotalTimeOfSecond() {
    double result = getTotalTimeOfMiliSecond();
    result /= 1000.0D;
    result = Double.parseDouble(MathOperationUtils.round(result + "", 1));
    return result;
  }
  
  public static double getTotalTimeOfMinute() {
    double result = getTotalTimeOfMiliSecond();
    result /= 60000.0D;
    result = Double.parseDouble(MathOperationUtils.round(result + "", 1));
    return result;
  }
  
  public static void listSystemProperties() {
    Properties props = System.getProperties();
    props.list(System.out);
  }
  
  public static String getJVMMemoryInfo() {
    Runtime currRuntime = Runtime.getRuntime();
    int nFreeMemory = (int)(currRuntime.freeMemory() / 1024L / 1024L);
    int nTotalMemory = (int)(currRuntime.totalMemory() / 1024L / 1024L);
    String result = nFreeMemory + "MB/" + nTotalMemory + "MB(free/total)";
    return result;
  }
}
